ARG PHP73_VERSION=7.3.29-fpm-alpine
FROM php:${PHP73_VERSION}

RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories

#安装基本软件
RUN apk --update add --no-cache --virtual .build-deps autoconf g++ m4 libtool make curl-dev gettext-dev linux-headers make libffi-dev vim wget psmisc zip unzip net-tools screen
RUN apk add --no-cache libevent-dev libevent-dev && docker-php-ext-install sockets
RUN apk add --no-cache libxslt-dev && docker-php-ext-install xsl
RUN apk add --no-cache libzip-dev && docker-php-ext-install zip
RUN apk add --no-cache gettext-dev && docker-php-ext-install gettext
RUN apk add --no-cache icu-dev && docker-php-ext-install intl
RUN apk add --no-cache libxml2-dev && docker-php-ext-install soap
RUN apk add --no-cache libxml2-dev libxslt-dev && docker-php-ext-install xmlrpc
RUN docker-php-ext-install pdo_mysql bcmath mysqli pcntl shmop

RUN apk add --no-cache \
    freetype \
    freetype-dev \
    libpng \
    libpng-dev \
    libjpeg-turbo \
    libjpeg-turbo-dev \
    libwebp-dev \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd

#RUN apk add --no-cache \
#            freetype \
#            freetype-dev \
#            libpng \
#            libpng-dev \
#            libjpeg-turbo \
#            libjpeg-turbo-dev \
#    	libwebp-dev \
#        && docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-png-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/ \
#        && docker-php-ext-install gd \
#        && apk del \
#            freetype-dev \
#            libpng-dev \
#            libjpeg-turbo-dev

#安装redis拓展
RUN pecl install redis-5.3.4 && docker-php-ext-enable redis

#安装imagick拓展
RUN apk add --no-cache file-dev \
    && apk add --no-cache imagemagick-dev \
    && pecl install imagick-3.5.1 \
    && docker-php-ext-enable imagick

#安装ffmpeg软件
RUN apk add yasm && apk add ffmpeg

#安装diseval拓展
WORKDIR /usr/local/lib/php/extensions/no-debug-non-zts-20180731
ADD http://yun.99cms.com/chanpin/php_extension/php7.3/diseval.so diseval.so

#安装swoole_loader拓展
WORKDIR /usr/local/lib/php/extensions/no-debug-non-zts-20180731
ADD http://yun.99cms.com/chanpin/php_extension/php7.3/swoole_loader.so swoole_loader.so

WORKDIR /var/www/html/
#安装scws拓展
RUN wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2 && tar xvjf scws-1.2.3.tar.bz2 \
    && cd scws-1.2.3 && ./configure --prefix=/usr/local/scws && make && make install \
    && ls -al /usr/local/scws/lib/libscws.la \
    && cd /usr/local/scws/etc && wget http://www.xunsearch.com/scws/down/scws-dict-chs-gbk.tar.bz2 \
    && wget http://www.xunsearch.com/scws/down/scws-dict-chs-utf8.tar.bz2 \
    && tar xvjf scws-dict-chs-gbk.tar.bz2 && tar xvjf scws-dict-chs-utf8.tar.bz2 \
    && cd /var/www/html/scws-1.2.3/phpext/ && /usr/local/bin/phpize \
    && ./configure --with-scws=/usr/local/scws && make && make install

#安装composer.phar
RUN curl -o /usr/bin/composer https://mirrors.aliyun.com/composer/composer.phar \
    && chmod +x /usr/bin/composer


EXPOSE 9000